package com.cskaoyan.wordmemorize.controller.app;


import com.cskaoyan.wordmemorize.auth.SaUserCheckPermission;
import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.UserVocAISituationDTO;
import com.cskaoyan.wordmemorize.dto.app.AIReviewReadDTO;
import com.cskaoyan.wordmemorize.request.AIReviewReadCommand;
import com.cskaoyan.wordmemorize.service.UserPrivilegeService;
import com.cskaoyan.wordmemorize.service.UserPrivilegeService_WF;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user/priviledge")
public class UserPrivilegeController_WF {

    @Resource
    UserPrivilegeService_WF userPrivilegeService;

    @Operation(summary = "***AI阅读剩余免费使用次数",
            description = "进入AI阅读后，由剩余免费使用次数决定显示的是免费使用，还是消耗xx单词上限",
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "成功"
                    ),
                    @ApiResponse(responseCode = "500",
                            description = "请求失败"
                    )
            }
    )
    @PostMapping("review/ai/read/free")
    public Result<Integer> getUserVocAIReadRemainFreeCount() {
        Long userId = StpKit.USER.getLoginIdAsLong();
        Integer count = userPrivilegeService.getUserVocAIReadRemainFreeCount(userId);
        return Result.ok(count);
    }

    @Operation(summary = "**AI阅读风格",
            description = "点击今日回顾中的AI阅读前先获取所需的生成风格",
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "成功"
                    ),
                    @ApiResponse(responseCode = "500",
                            description = "请求失败"
                    )
            }
    )
    @PostMapping("review/ai/read/options")
    //@SaUserCheckPermission("user:review:ai:read")
    public Result<List<UserVocAISituationDTO>> getAIReviewReadOptions() {
        List<UserVocAISituationDTO> aiReviewReadOptions = userPrivilegeService.getAIReviewReadOptions();
        return Result.ok(aiReviewReadOptions);
    }

    /**
     *  AI阅读
     */
    @Operation(summary = "****AI阅读",
            description = "点击今日回顾中的AI阅读，选择20个单词生成，选择生成对话或者文章",
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "成功"
                    ),
                    @ApiResponse(responseCode = "500",
                            description = "请求失败"
                    )
            }
    )
    @PostMapping("review/ai/read")
    //@SaUserCheckPermission("user:review:ai:read")
    public Result<List<AIReviewReadDTO>> getAIReviewRead(@RequestBody AIReviewReadCommand commands) {
        Long userId = StpKit.USER.getLoginIdAsLong();
        List<AIReviewReadDTO> aiReviewRead = userPrivilegeService.getAIReviewReadContent(commands, userId);
        return Result.ok(aiReviewRead);
    }



}
